//
//  ZCAttentionListCell.m
//  百思不得姐
//
//  Created by Ning Xie on 16/8/24.
//  Copyright © 2016年 zhangchong. All rights reserved.
//

#import "ZCAttentionListCell.h"
#import "ZCAttentionListModel.h"

@interface ZCAttentionListCell ()

@property (nonatomic, strong) UIView *scrollView;
@end

@implementation ZCAttentionListCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.scrollView = [[UIView alloc]init];
        self.scrollView.backgroundColor = [UIColor redColor]; 
        
        [self.contentView addSubview:_scrollView];
        
        self.textLabel.font = [UIFont systemFontOfSize:15];
        
    }
    return self;
}

-(void)setModel:(ZCAttentionListModel *)model
{
    _model = model;
    self.textLabel.text = model.name;
    self.textLabel.textAlignment = NSTextAlignmentCenter;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.textLabel.frame = CGRectMake(0, 0, self.width, self.height);
    
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.leading.mas_equalTo(self.contentView);
        make.width.mas_equalTo(5);
    }];
}

-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
    [super setSelected:selected animated:animated];
    
    self.scrollView.hidden = !selected;
    self.textLabel.textColor = selected?self.scrollView.backgroundColor:[UIColor blackColor];
    
//    ZCLog(@"%@-----%d",self.textLabel.text,selected);
    
}


-(void)setFrame:(CGRect)frame{
    
    
    frame.size.height -= 1;

    [super setFrame:frame];
}
@end
